﻿{{include file="../00_include/01_head.tpl"}}
<script type="text/javascript">var base_url = "/", edialog, ndialog;</script>
<div class='l-h-28 g-d-w  b-r-t-4 p-l-20 b-d-b-c-ddd p-r'>
    <span>Home</span>
    <span class="arrow_space"></span>
    <span>Content</span>
    <span class="arrow_space"></span>
    <span>{{$type|default:'All'|ucwords}}</span>
    <span class="arrow_space"></span>
    <span>Editor</span>
    <div class="p-a t-8 r-8 l-h-16 z-i-100">
        <a class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p add-icon" href="/admincp/backend/content/editor?type={{$type}}">Add</a>
        <span class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p save-icon" onclick='news_save()'>Save</span>
        <a class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p grid-icon" href="/admincp/backend/content/index/{{$type}}">Grid</a>
        <span class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p menu-icon" onclick="accessdenied()">Menu</span>
    </div>
</div>
<div class="grid_12- p-a- t-0- l-0- b-0- b-g-c-w- z-i-1 ">
    <div id="gridview" class="frmjqxgrid p-r">


        <input 
            type="hidden" 
            value="{{$item->news_title}}" 
            id="news_title_curent" name="news_title_curent"
            />
        <form id="news_frm" name="news_frm" action="/admincp/backend/excution" method="POST" 
              onsubmit="return false;" 
              target="integration_asynchronous" autocomplete="off" 
              >
            
                <div class="w-720 m-0-a p-40">

                    <div class="p-r p-b-12">
                        <p>Category</p>
                        <div class="p-r b-g-c-w">
                            {{function catitem level=0}}
                            {{foreach $data as $cat}}
                                {{if isset($item)}}
                                    {{if $cat->cate_parent==$level and $item->news_category==$cat->cate_id}}
                                        <option selected="1" value="{{$cat->cate_id}}">
                                            {{$cat->cate_title}}
                                        </option>
                                        {{catitem data=$data level=$cat->cate_id}}
                                    {{else if $cat->cate_parent==$level}}
                                        <option value="{{$cat->cate_id}}">
                                            {{$cat->cate_title}}
                                        </option>
                                        {{catitem data=$data level=$cat->cate_id}}
                                    {{/if}}
                                {{else}}
                                    {{if $cat->cate_parent==$level}}
                                        <option value="{{$cat->cate_id}}">
                                            {{$cat->cate_title}}
                                        </option>
                                        {{catitem data=$data level=$cat->cate_id}}
                                    {{/if}}
                                {{/if}}
                            {{/foreach}}
                            {{/function}}
                            <select id="news_category" class="w-i p-r t-0 l-0" name="news_category">
                                <!--                            <option value="0">Root</option>-->
                                {{catitem data=$categories level=0}}
                            </select>
                        </div>
                        <p class="erc"></p>
                    </div>
                    <div class="clear"></div>
                    <!--      title      -->
                    <div class="p-r p-b-12">
                        <p>Title (*)</p>
                        <div class="p-r">
                            <input 
                                type="text" onblur="AliasTo('#news_title','#news_alias')"
                                class="w-i b-g-c-w validate[required]" 
                                value="{{$item->news_title|escape:'html'}}" 
                                minlength="10"
                                maxlength="120" 
                                id="news_title" name="news_title"
                                />

                            <input 
                                type="hidden" 
                                value="{{$item->news_id}}" 
                                id="news_id" name="news_id"
                                />
                        </div>
                    </div>
                    <div class="clear"></div>
                    <!--      alias      -->
                    <div class="p-r p-b-12">
                        <p><label class="d-p-b w-i" for="news_alias">Alias (*)</label></p>
                        <div class="p-r">
                            <input 
                                type="text" 
                                class="w-i b-g-c-w validate[required,custom[alias]]" 
                                value="{{$item->news_alias|escape:'html'}}" 
                                minlength="10"
                                maxlength="120" 
                                id="news_alias" name="news_alias"
                                />
                        </div>
                    </div>
                    <div class="clear"></div>
                    <!--      parent      -->
                    <div class="p-r p-b-12">
                        <p>Thumb</p>
                        <div class="p-r">
                            <input 
                                type="text"
                                class="w-i b-g-c-w" 
                                value="{{$item->news_thumb|escape:'html'}}" 
                                minlength="10"
                                maxlength="120" 
                                id="news_thumb" name="news_thumb"
                                />
                            <span class="icon-16 more p-a t-4 r-0 c-s-p" title="Browse Images" onclick="BrowseServer('#news_thumb')"></span>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="p-r p-b-12">
                        <p>Description</p>
                        <div class="p-r">
                            <textarea id="news_desc" name="news_desc" class="w-i">{{$item->news_desc|escape:'html'}}</textarea>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="p-r p-b-12">
                        <p>Tag</p>
                        <div class="p-r">
                            <textarea id="news_tag" name="news_tag" class="w-i">{{$item->news_tag|escape:'html'}}</textarea>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="p-r p-b-12 f-l">
                        <div class="f-l w-160">
                            <!--      birth      -->
                            <div class="p-l-2 p-r-2">
                                <div class="p-r">
                                    <p><label class="d-p-b w-i" for="news_status">Status (*)</label></p>
                                    <div class="p-r">
                                        <select id="news_status" name="news_status" class="w-i">
                                            <option {{if $item->news_status=='true'}}selected="1"{{/if}} value="true">Public</option>
                                            <option {{if $item->news_status=='false'}}selected="1"{{/if}} value="false">Private</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="f-l w-160">
                            <!--      year      -->
                            <div class="p-l-2">
                                <div class="p-r">
                                    <p><label class="d-p-b w-i" for="news_type">Type (*)</label></p>
                                    <div class="p-r">

                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="clear"></div>
                        <p id="gr-err-1" class="erb"></p>
                    </div>
                    <div class="clear"></div>
                    <div class="p-r">
                        <textarea id="news_content" name="news_content" class="w-i">{{$item->news_content}}</textarea>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="clear"></div>
                
<!--                <div class="p-r p-l-20 p-b-12 t-a-c">
                    <div id="step-3-next" onclick="news_save()" class="b-t-c g-d-w">Save</div>
                    <div id="step-3-back" onclick="menu.Cancel()" class="b-t-c g-d-w m-r-8">Cancel</div>
                    <div class="clear"></div>
                </div>-->
            <div class="clear"></div>
        </form>




        <div class="d-p-b h-28 b-d-t-c-ddd"></div>
        <div class="p-a b-4 l-8 l-h-16 z-i-100 p-b-2">
            <a class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p add-icon" href="/admincp/backend/content/editor">Add</a>
            <span class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p save-icon" onclick='_save()'>Save</span>
            <a class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p grid-icon" href="/admincp/backend/content">Grid</a>
            <span class="l-h-16 p-l-20 p-r-8 f-l hover-50 c-s-p menu-icon" onclick="accessdenied()">Menu</span>
        </div>
    </div>
</div>
<script>
    function AliasTo(from,element){
        if($(from).val()==$(from+'_curent').val())return;
        var url="/admincp/backend/excution/getalias";
        var data={text:$(from).val()};
        var proc=new backend({
            url:url,data:data,
            callback:function(rsdata){
                if(rsdata.result===1){
                    $(element).val(rsdata.alias);
                    $(from+'_curent').val($(from).val());
                }else{
                    edialog.open(rsdata.message);
                }
            }
        }).call();
    }
    function _save(){
        tinyMCE.triggerSave(false,false);
        if( $('#news_frm').validationEngine('validate') === false)return false;
        new backend({
            url         :   "/admincp/backend/content/save",
            data        :   $('#news_frm').serialize(),
            callback    :   function(data){
                if(data.result<0){
                    new bckdialog({type:'error'}).open(data.message);
                }else{
                    uiMessage(data.message);
                }
                console.log(data);
            }
        }).call();
        return false;
    }
    $(document).ready(function(){
        $( "#tabs" ).tabs();
        addEditorContent('news_content',400);
        $("#news_frm").validationEngine();
    });
</script>
{{include file="../00_include/02_foot.tpl"}}